/* Android-Michi is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published
 * by the Free Software Foundation; either version 2 of the License,
 * or (at your option) any later version.
 *
 * Android-Michi is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with Android-Michi; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
 * USA
 */

package view;

import android.app.Activity;
import com.google.ads.AdRequest;
import com.google.ads.AdSize;
import com.google.ads.AdView; 

import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.Toast;
import com.chaski.michi.*;


public class DisplayManager {
	Activity activity;
	LinearLayout layout;
	private AdView adView;


	public DisplayManager(Activity _activity) {
		activity = _activity;
		activity.setContentView(R.layout.activity_michi);

		// prepare the advertisement 
		adView = new AdView(activity, AdSize.BANNER, "XXXXXXXXXXXXX");       
		LinearLayout layout = (LinearLayout) activity.findViewById(R.id.linearLayout);
		layout.addView(adView);
		AdRequest adRequest = new AdRequest();		 
//		adRequest.addTestDevice(AdRequest.TEST_EMULATOR);
//		adRequest.addTestDevice("XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"); 
		adView.loadAd(adRequest);
	}

	public void displayBlankGrid() {	
		display00(' ');
		display10(' ');
		display20(' ');
		display01(' ');
		display11(' ');
		display21(' ');
		display02(' ');
		display12(' ');
		display22(' ');
	}

	public void display00(char value) {
		Button button;
		button = (Button)activity.findViewById(R.id.btnButton00);
		button.setText(""+value);
	}

	public void display01(char value) {
		Button button;
		button = (Button)activity.findViewById(R.id.btnButton01);
		button.setText(""+value);
	}
	public void display02(char value) {
		Button button;
		button = (Button)activity.findViewById(R.id.btnButton02);
		button.setText(""+value);
	}


	public void display10(char value) {
		Button button;
		button = (Button)activity.findViewById(R.id.btnButton10);
		button.setText(""+value);
	}
	public void display11(char value) {
		Button button;
		button = (Button)activity.findViewById(R.id.btnButton11);
		button.setText(""+value);
	}
	public void display12(char value) {
		Button button;
		button = (Button)activity.findViewById(R.id.btnButton12);
		button.setText(""+value);
	}

	public void display20(char value) {
		Button button;
		button = (Button)activity.findViewById(R.id.btnButton20);
		button.setText(""+value);
	}
	public void display21(char value) {
		Button button;
		button = (Button)activity.findViewById(R.id.btnButton21);
		button.setText(""+value);
	}
	public void display22(char value) {
		Button button;
		button = (Button)activity.findViewById(R.id.btnButton22);
		button.setText(""+value);
	}

	public void displayMessage(String string) {
		Toast.makeText(activity.getApplicationContext(), string, Toast.LENGTH_SHORT).show();
	}
	
	public void displayMessage(int _string) {
		String string = activity.getResources().getString(_string);
		Toast.makeText(activity.getApplicationContext(), string, Toast.LENGTH_SHORT).show();
	}
	
	public void displayWinner(int _winner) {
		String string = activity.getResources().getString(_winner);
		String winneris = activity.getResources().getString(R.string.winner_is_string);
		Toast.makeText(activity.getApplicationContext(), winneris+string, Toast.LENGTH_SHORT).show();
	}
}
